package com.example.demo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.entity.Account;
import com.example.demo.mapper.AccountMapper;
import com.example.demo.service.IAccountService;
import com.mybatisflex.core.query.QueryWrapper;

import static com.example.demo.entity.table.AccountTableDef.ACCOUNT;

import java.util.List;

@Service
public class AccountServiceImpl implements IAccountService {

    @Autowired
    private AccountMapper accountMapper;
    
    public List<Account> getAccounts() {
        return accountMapper.selectAll();
    }

    public List<Account> getAccountsByAge(int age) {
        QueryWrapper queryWrapper = QueryWrapper.create()
            .select()
            .where(ACCOUNT.AGE.eq(age));
        return accountMapper.selectListByQuery(queryWrapper);
    }
}
